/*
 * tester.java
 *
 * Created on March 20, 2007, 12:50 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.mystuff;

/**
 *
 * @author Sam Griffiths
 */
public class tester {
    
    storeBO store;
    employeeBO emp;
    customerBO cust;
    
    /** Creates a new instance of tester */
    public tester() {
    }
    
    public tester(storeBO store, customerBO cust, employeeBO emp){
        this.store = store;
        this.cust = cust;
        this.emp = emp;
    }
    
    public void processATransaction(){
        try{
        //create and initialize a revBO object    
        revDAO rd = revDAO.getInstance();
        revBO r = rd.create();
        r.setPrice(1000.00);
        r.setType("Sale");
        rd.save(r);
        //System.out.println(r.toString());
        
        //create and initialize a couponBO object
        couponDAO cd = couponDAO.getInstance();
        couponBO c = cd.create();
        c.setAmount(5.00);

        //create and initialize a transactionLine object
        tlineDAO tld = tlineDAO.getInstance();
        tlineBO tl = tld.create();
        //link coupon to transactionline
        tl.setCoupon(c);
        //link revenuesource to transactionline
        tl.setRevenueSource(r);
        c.setTransactionLineId(tl.getTransactionLineId());
        tl.setRevSource(r.getRevenueId());
        
        //create new transactionBO, tie a transactionline to it
        String x = "xxx";
        transDAO td = transDAO.getInstance();
        transBO trn = td.create();
        trn.add(tl);
        trn.calculatePrice();
        trn.setStoreId(store.getStoreId());
        trn.setComplete(true);
        trn.setEmployeeId(emp.getEmpId());
        trn.setCustId(cust.getId());
        
        /*paymentDAO pd = paymentDAO.getInstance();
        paymentBO pmt = pd.create();
        pmt.setPaymentType("Credit");
        pmt.setAmountPaid(1064.65);
        pmt.setChange(0.0);
        trn.setPayment(pmt);*/
        
        td.save(trn);
        //System.out.println(Double.toString(trn.getTotal()));
        //System.out.println(trn.toString());

        //td.save(tl);
        }catch(DataException e){System.out.println("error thrown ni tester");}
    }
    
    public void processReturn(){
        int x;
    }
}
